<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>合伙人管理</title>
    <link rel="stylesheet" href="css/font-awesome.min.css"/>
    <link rel="stylesheet" href="css/font-awesome-ie7.min.css"/>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link href="css/jquery.datetimepicker.css" rel="stylesheet">
    <link rel="stylesheet" href="css/admin.css"/>

    <link rel="stylesheet" type="text/css" href="css/paging.css">

    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <![endif]-->
    <!--[if lt IE 10]>
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/jquery-placeholder/2.0.8/jquery.placeholder.min.js"></script>
    <![endif]-->
</head>
<body>
<div id="gray_bg"></div>
<!-- 编辑合伙人开始 -->
<div id="editDiadog" class="diadog">
    <div class="diadog-tit">
        <div class="row">
            <div class="col-md-11" id="diadogTitle"><span>添加合伙人</span></div>
            <div class="col-md-1 close"><span>×</span></div>
        </div>
    </div>
    <div class="diadog-con">
        <div class="form-horizontal" role="form">
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">用户名:</label>
                <div class="col-sm-9">
                    <input id="partnerName" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">企业名:</label>
                <div class="col-sm-9">
                    <input id="companyName" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">微信AppId:</label>
                <div class="col-sm-9">
                    <input id="wxAppId" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">微信App密钥:</label>
                <div class="col-sm-9">
                    <input id="wxSecret" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">联系电话:</label>
                <div class="col-sm-9">
                    <input id="linkPhone" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">管理员手机号:</label>
                <div class="col-sm-9">
                    <input id="miniAppPhone" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group" id="admin">
                <label for="inputPassword3" class="col-md-4 control-label">管理员账号:</label>
                <div class="col-sm-9">
                    <input id="adminAccount" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group" id="uploadImg">
                <label for="inputPassword3" class="col-md-4 control-label"><span
                        style="color: #e4393c"></span>合伙人logo:</label>
                <div class="col-sm-4">
                    <button style="margin-left: 0px" type="button" class="btn btn-default">上传图片
                    </button>
                    <input style="width:300px !important;height:60px !important;position: absolute !important;z-index: 100 !important;filter:alpha(opacity=0)!important;-moz-opacity:0 !important;-khtml-opacity:0 !important; opacity: 0 !important;top:0px; !important;cursor: pointer; left: 0px !important;"
                           id="pickfiles" type="file" class="form-control">
                    <input id="avatar" type="hidden" class="form-control">
                </div>
            </div>
            <div class="form-group" id="imageShow">
                <label for="inputPassword3" class="col-md-4 control-label">图片:</label>
                <span class="col-sm-2" style=" color: #000; margin-top: 15px;"><img id="imgName"
                                                                                    style="width: 80px;height: 80px;"></span>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label"><span style="color: #e4393c"></span>合伙人类型:</label>
                <div class="col-sm-9">
                    <div class="btn-group">
                        <button type="button" class="btn btn-default" id="toFactorTypeText">选择类型</button>
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu" id="">
                            <li><a onclick="toFactorType(this)" partnerType="A" href="javascript:;">合伙人有产品档案（A）</a></li>
                            <li><a onclick="toFactorType(this)" partnerType="B" href="javascript:;">合伙人只做展示(B)</a></li>
                            <li><a onclick="toFactorType(this)" partnerType="AB" href="javascript:;">两个都有(AB)</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-9">
                    <button id="savePartner" type="submit" class="btn btn-danger">保存</button>
                    <button id="editPartner" type="submit" class="btn btn-danger">保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 编辑合伙人结束 -->
<!-- 编辑账号开始 -->
<div id="editAccountDiadog" class="diadog">
    <div class="diadog-tit">
        <div class="row">
            <div class="col-md-11" id="diadogAccountTitle"><span>修改合伙人账号</span></div>
            <div class="col-md-1 close"><span>×</span></div>
        </div>
    </div>
    <div class="diadog-con">
        <div class="form-horizontal" role="form">
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">合伙人账号:</label>
                <div class="col-sm-9">
                    <input id="account" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-9">
                    <button id="saveAccount" type="submit" class="btn btn-danger">保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 编辑账号结束 -->
<!-- 二维码开始 -->
<div id="qrCodeDiadog" class="diadog" style="width: 430px;height: 460px">
    <div class="diadog-tit" style="width:430px;">
        <div class="row">
            <div class="col-md-11" id="diadogqrCodeTitle"><span>二维码</span></div>
            <div class="col-md-1 close"><span>×</span></div>
        </div>
    </div>
    <div class="diadog-con" style="width: 430px;height: 430px">
        <img id="qrCode" src="" alt="">
    </div>
</div>
<!-- 二维码结束 -->
<!-- 删除分类开始 -->
<div id="deleteDiadog" class="diadog">
    <div class="diadog-tit">
        <div class="row">
            <div class="col-md-11"><span id="delTitle">删除分类？</span></div>
            <div class="col-md-1 close"><span>×</span></div>
        </div>
    </div>
    <div class="diadog-con" style="padding:30px 0">

        <div class="form-horizontal" role="form">
            <div class="row">
                <div class="col-md-12"></div>

                <div class="form-group" style="text-align: center;">
                    <div class="col-md-1"></div>
                    <div class="col-md-2">
                        <button id="disableSure" type="submit" class="btn btn-primary">确 定</button>
                        <button id="enableSure" type="submit" class="btn btn-primary">确 定</button>
                    </div>
                    <div class="col-md-2">
                        <button id="btn-default" type="submit" class="btn btn-default">取 消</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 删除分类结束 -->
<div id="addressDialog" class="diadog" style="width: 800px;height: 680px;display: none">
    <div class="diadog-tit" style="width: 800px">
        <div class="row">
            <div class="col-md-11" id="addressTitle"><span>定位地理位置</span></div>
            <div class="col-md-1 close"><span>×</span></div>
        </div>
    </div>
    <div class="diadog-con" style="width: 700px">
        <div class="form-group">
            <div style="float: left" class="col-md-10">
                <label for="partnerAddress" class="control-label" style="float: left">地址:</label>
                <div style="margin-left:10px;float: left">
                    <input id="partnerAddress" type="text" class="form-control" style="width: 500px">
                </div>
            </div>
            <button id="btnGeoCoder" type="submit" class="btn btn-primary" style="float: right">转换坐标</button>
        </div>
        <div class="form-group">
            <div style="float: left;margin-top: 10px !important;margin-bottom: 5px;width: 700px">
                <label for="inputPassword3" class="col-md-2 control-label">经度:</label>
                <div class="col-md-3" style="margin-left: -60px !important;">
                    <input id="lng" disabled type="text" class="form-control">
                </div>
                <label for="inputPassword3" class="col-md-2 control-label">纬度:</label>
                <div class="col-md-3" style="margin-left: -60px !important;">
                    <input id="lat" disabled type="text" class="form-control">
                </div>
                <button id="sureAddr" type="submit" class="btn btn-primary" style="float: right">确定</button>
            </div>
        </div>
    </div>
    <div style="width: 780px;height: 530px;margin-left: 10px" id="mapContainer">

    </div>
</div>
<!--修改微名片信息开始-->
<div id="editvCardDiadog" class="diadog" style="display: none">
    <div class="diadog-tit">
        <div class="row">
            <div class="col-md-11"><span>修改微名片信息</span></div>
            <div class="col-md-1 close"><span>×</span></div>
        </div>
    </div>
    <div class="diadog-con">
        <div class="form-horizontal" role="form">
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">职位:</label>
                <div class="col-sm-9">
                    <input id="jobTitle" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">主页地址:</label>
                <div class="col-sm-9">
                    <input id="homeURL" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">QQ账号:</label>
                <div class="col-sm-9">
                    <input id="partnerQQ" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label"><span
                        style="color: #e4393c"></span>QQ二维码:</label>
                <div class="col-sm-8">
                    <button style="margin-left: 0px" type="button" class="btn btn-default">上传图片
                    </button>
                    <span id="printFileDetail1"></span>
                    <input style="width:300px !important;height:60px !important;position: absolute !important;z-index: 100 !important;filter:alpha(opacity=0)!important;-moz-opacity:0 !important;-khtml-opacity:0 !important; opacity: 0 !important;top:0px; !important;cursor: pointer; left: 0px !important;"
                           id="pickfiles1" type="file" class="form-control">
                    <input id="projectyFil1" type="hidden" class="form-control">
                </div>
            </div>
            <div  class="form-group" id='speedProduct1' style='display: none;line-height: 30px'>
                文件大小：<span style="color: #e4393c;margin-right:10px;" id="fileSizes1"></span>
                已上传：<span style="color: #e4393c;margin-right:10px;" id="Sizes1"></span>
                上传速度：<span style="color: #e4393c;margin-right:10px;" id="formatSpeeds1"></span>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">微信账号:</label>
                <div class="col-sm-9">
                    <input id="weixinAccount" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label"><span
                        style="color: #e4393c"></span>微信二维码:</label>
                <div class="col-sm-8">
                    <button style="margin-left: 0px" type="button" class="btn btn-default">上传图片
                    </button>
                    <span id="printFileDetail2"></span>
                    <input style="width:300px !important;height:60px !important;position: absolute !important;z-index: 100 !important;filter:alpha(opacity=0)!important;-moz-opacity:0 !important;-khtml-opacity:0 !important; opacity: 0 !important;top:0px; !important;cursor: pointer; left: 0px !important;"
                           id="pickfiles2" type="file" class="form-control">
                    <input id="projectyFil2" type="hidden" class="form-control">
                </div>
            </div>
            <div  class="form-group" id='speedProduct2' style='display: none;line-height: 30px'>
                文件大小：<span style="color: #e4393c;margin-right:10px;" id="fileSizes2"></span>
                已上传：<span style="color: #e4393c;margin-right:10px;" id="Sizes2"></span>
                上传速度：<span style="color: #e4393c;margin-right:10px;" id="formatSpeeds2"></span>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">邮箱:</label>
                <div class="col-sm-9">
                    <input id="email" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label"><span
                        style="color: #e4393c"></span>全景图:</label>
                <div class="col-sm-8">
                    <button style="margin-left: 0px" type="button" class="btn btn-default">上传图片
                    </button>
                    <span>[宽小于2000px]</span><br>
                    <span id="printFileDetail3"></span>

                    <input style="width:300px !important;height:60px !important;position: absolute !important;z-index: 100 !important;filter:alpha(opacity=0)!important;-moz-opacity:0 !important;-khtml-opacity:0 !important; opacity: 0 !important;top:0px; !important;cursor: pointer; left: 0px !important;"
                           id="pickfiles3" type="file" class="form-control">
                    <input id="projectyFil3" type="hidden" class="form-control">
                </div>
            </div>
            <div  class="form-group" id='speedProduct3' style='display: none;line-height: 30px'>
                文件大小：<span style="color: #e4393c;margin-right:10px;" id="fileSizes3"></span>
                已上传：<span style="color: #e4393c;margin-right:10px;" id="Sizes3"></span>
                上传速度：<span style="color: #e4393c;margin-right:10px;" id="formatSpeeds3"></span>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label"><span
                        style="color: #e4393c"></span>名片声音:</label>
                <div class="col-sm-8">
                    <button style="margin-left: 0px" type="button" class="btn btn-default">上传音频
                    </button>
                    <span id="printFileDetail4"></span>
                    <input style="width:300px !important;height:60px !important;position: absolute !important;z-index: 100 !important;filter:alpha(opacity=0)!important;-moz-opacity:0 !important;-khtml-opacity:0 !important; opacity: 0 !important;top:0px; !important;cursor: pointer; left: 0px !important;"
                           id="pickfiles4" type="file" class="form-control">
                    <input id="projectyFil4" type="hidden" class="form-control">
                </div>
            </div>
            <div  class="form-group" id='speedProduct4' style='display: none;line-height: 30px'>
                文件大小：<span style="color: #e4393c;margin-right:10px;" id="fileSizes4"></span>
                已上传：<span style="color: #e4393c;margin-right:10px;" id="Sizes4"></span>
                上传速度：<span style="color: #e4393c;margin-right:10px;" id="formatSpeeds4"></span>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label">视频标题:</label>
                <div class="col-sm-9">
                    <input id="cardMediaTitle" type="text" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-md-4 control-label"><span
                        style="color: #e4393c"></span>名片视频:</label>
                <div class="col-sm-8">
                    <button style="margin-left: 0px" type="button" class="btn btn-default">上传视频
                    </button>
                    <span id="printFileDetail5"></span>
                    <input style="width:300px !important;height:60px !important;position: absolute !important;z-index: 100 !important;filter:alpha(opacity=0)!important;-moz-opacity:0 !important;-khtml-opacity:0 !important; opacity: 0 !important;top:0px; !important;cursor: pointer; left: 0px !important;"
                           id="pickfiles5" type="file" class="form-control">
                    <input id="projectyFil5" type="hidden" class="form-control">
                </div>
            </div>
            <div  class="form-group" id='speedProduct5' style='display: none;line-height: 30px'>
                文件大小：<span style="color: #e4393c;margin-right:10px;" id="fileSizes5"></span>
                已上传：<span style="color: #e4393c;margin-right:10px;" id="Sizes5"></span>
                上传速度：<span style="color: #e4393c;margin-right:10px;" id="formatSpeeds5"></span>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-9">
                    <!--<button id="savevCard" type="submit" class="btn btn-danger">保存</button>-->
                    <button id="editvCard" type="submit" class="btn btn-danger">保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 编辑微名片信息结束 -->
<!-- header start -->
<div id="header" class="header">

</div>
<!-- header end -->
<!-- usercenter start -->
<div class="usercotent">
    <div id="center-left"></div>
    <div class="usercotentr floatr">
        <div class="user-tit" style="margin-bottom:10px">
            <h3>合伙人管理</h3>
        </div>
        <div class="usercotent-con">
            <div class="col-md-12">
                <button id="addPartner" type="button" class="btn btn-danger pull-right">添加合伙人</button>
            </div>


            <div class="down">
                <table id="testMyGrid" class="table table-bordered table-hover"></table>
            </div>
            <!-- page start -->
            <nav class="totalpage floatr">
                <span>总共</span><strong id="totalpage"></strong><span>条</span>
                <div id="pageTool" style="margin-top:20px;"></div>
            </nav>
            <div class="clear"></div>
            <!-- page end -->
        </div>

    </div>
    <div class="clear"></div>
</div>

<!-- usercenter end -->

<!-- footer start -->
<div class="footer">
    <div class="bot">
        <p style="padding-top: 10px; text-align: center">Copyright (C) 都能印 2014-2016, all Rights Reserved |
            豫ICP备14024464号-1 | 增值电信业务经营许可证：豫B2-20150019</p>
        <p class="authentication" style="padding-bottom: 10px; padding-top: 10px;">
            <img src="img/footer1.png" alt="">
            <img src="img/footer2.png" alt="">
            <img src="img/footer3.png" alt="">
            <img src="img/footer4.png" alt="">
            <img src="img/footer5.png" alt="">
        </p>
    </div>
</div>
<!-- footer end -->
<script src="js/jquery.min-1-11-3.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/widget/myDataGrid.js"></script>
<script src="js/widget/admin.js"></script>
<script type="text/javascript" src="js/query.js"></script>
<script type="text/javascript" src="js/paging.js"></script>
<script type="text/javascript" src="bower_components/plupload/js/plupload.full.min.js"></script>
<script type="text/javascript" src="js/ui.js"></script>
<script type="text/javascript" src="js/qiniu.min.js"></script>
<script type="text/javascript" src="js/upload.js"></script>
<script type="text/javascript" src="js/uploadFive.js"></script>
<script type="text/javascript">
    var id;
    var map, marker = null;
    //地图API功能
    function loadMapJScript() {
        //创建script标签
        var script = document.createElement("script");
        //设置标签的type属性
        script.type = "text/javascript";
        //设置标签的链接地址
        script.src = "https://map.qq.com/api/js?v=2.exp&key=DPEBZ-NYUCP-257DT-LSOJI-YMB3O-MUFYR&callback=initMap";
        //添加标签到dom
        document.body.appendChild(script);
    }
    function initMap() {
        //设置地图中心点
        var myLatlng = new qq.maps.LatLng(39.916527, 116.397128);
        //定义工厂模式函数
        var myOptions = {
            zoom: 8,               //设置地图缩放级别
            center: myLatlng,      //设置中心点样式
            mapTypeId: qq.maps.MapTypeId.ROADMAP  //设置地图样式详情参见MapType
        };
        //获取dom元素添加地图信息
        map = new qq.maps.Map(document.getElementById("mapContainer"), myOptions);

        qq.maps.event.addListener(map, 'click', function (event) {
            var latLng = event.latLng,
                lat = latLng.getLat().toFixed(5),
                lng = latLng.getLng().toFixed(5);
//            console.log("点击地图坐标为，经度：" + lng + "纬度：" + lat);
            $("#lat").val(lat);
            $("#lng").val(lng);
            var curPlace = new qq.maps.LatLng(lat, lng);
            map.setCenter(curPlace);
            map.zoomTo(18);
            if (marker != null) {
                marker.setMap(null);
            }
            //设置marker标记
            marker = new qq.maps.Marker({
                map: map,
                position: curPlace
            });
        });
    }

    //开始
    $(function () {
        initSideAccMenu("合伙人管理", "合伙人列表");
        loadMapJScript();
//        获取数据
        $("#testMyGrid").grid({
            id: "testMyGrid",
            pageTotalId: "totalpage",
            pageToolId: "pageTool",
            url: "apis/user/getpartnerpagelist",
            columns: [
                {field: 'partnerKind', title: '类型', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                {field: 'partnerName', title: '用户名', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                {field: 'companyName', title: '企业名', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                {field: 'adminAccount', title: '管理账号', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                {field: 'linkPhone', title: '联系电话', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                {field: 'wxAppId', title: '微信AppId', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                {field: 'cusname', title: '操作', conmethod: 'getUserOptURL', calcfield: '', kind: '', region: 1}
            ],
            pagesize: 20
        });
    });
    var partnerType = "";
    function toFactorType(e) {
        $("#toFactorTypeText").html($(e).html());
        partnerType = $(e).attr("partnerType");
    }
    //    操作
    function getUserOptURL() {
        var user = arguments[1];
        var shtml = "";
        shtml += "<a onclick=\"toEditpartner(" + user.partnerId + ",'" + user.partnerName + "','" + user.companyName + "','" + user.linkPhone + "','" + user.wxAppId + "','" + user.wxSecret + "','" + user.miniAppPhone + "','" + user.avataImage + "','" + user.partnerKind + "')\"" + " href=\"javascript:;\">修改合伙人</a>";
        shtml += "&nbsp&nbsp&nbsp";
        shtml += "<a onclick=\"toEditaccount(" + user.partnerId + ",'" + user.adminAccount + "')\"" + " href=\"javascript:;\">修改账号</a>";
        shtml += "&nbsp&nbsp&nbsp";
        shtml += "<a href='partner-advertising.html?partnerId=" + user.partnerId + "'>轮播广告管理</a>";
        shtml += "&nbsp&nbsp&nbsp<br>";
        shtml += "<a onclick=\"toCode(" + user.partnerId + ")\"" + " href=\"javascript:;\">查看二维码</a>";
        shtml += "&nbsp&nbsp&nbsp";
        shtml += "<a onclick=\"toMap(" + user.partnerId + ")\"" + " href=\"javascript:;\">定位地址设置</a>";
        shtml += "&nbsp&nbsp&nbsp";
        shtml += "<a onclick=\"toErCode(" + user.partnerId + ")\"" + " href=\"javascript:;\">获取商户分享二维码</a>";
        shtml += "&nbsp&nbsp&nbsp<br>";
        shtml += "<a onclick=\"toEditvCard(" + user.partnerId + ")\"" + " href=\"javascript:;\">修改微名片信息</a>";
        shtml += "&nbsp&nbsp&nbsp";
        shtml += "<a onclick=\"tovCard(" + user.partnerId + ")\"" + " href=\"javascript:;\">获取通讯录二维码</a>";
//        shtml += "&nbsp&nbsp&nbsp";
//        shtml += "<a href='partner-innerAccount.html?partnerId="+user.partnerId+"'>内部账号管理</a>";
        return shtml;
    }
    //手机号验证
    //    $("#linkPhone").blur(function () {
    //        var account = $("#linkPhone").val();
    //        if (account && /^1[3|4|5|7|8]\d{9}$/.test(account)) {
    //
    //        } else {
    //            alert("请输入正确手机号")
    //            return;
    //        }
    //    });
    //    $("#miniAppPhone").blur(function () {
    //        var account = $("#miniAppPhone").val();
    //        if (account && /^1[3|4|5|7|8]\d{9}$/.test(account)) {
    //
    //        } else {
    //            alert("请输入正确手机号")
    //            return;
    //        }
    //    });
    //    修改合伙人
    var partnerId;
    //修改微名片信息
    function toEditvCard(id) {
        partnerId = id;
        $("#gray_bg").show();
        $("#gray_bg").css({"height": $(document).height()});
        $("#editvCardDiadog").show();
        $("#editvCardDiadog").center();

        $.ajax({
            url: '/apis/user/getPartnerCard',
            type: 'post',
            data: {
                "partnerId": partnerId,
            },
            dataType: 'json',
            contentType: 'application/json',
            success: function (res) {
                if(res.httpCode == 200){
                    var data = res.data;
                    if(data.jobTitle == null || data.jobTitle == "null"){
                        $("#jobTitle").val("");
                    }else{
                        $("#jobTitle").val(data.jobTitle);
                    }
                    if(data.homeURL == null || data.homeURL == "null"){
                        $("#homeURL").val("");
                    }else{
                        $("#homeURL").val(data.homeURL);
                    }
                    if(data.cardMediaTitle == null || data.cardMediaTitle == "null"){
                        $("#cardMediaTitle").val("");
                    }else{
                        $("#cardMediaTitle").val(data.cardMediaTitle);
                    }
                    if(data.partnerQQ == null || data.partnerQQ == "null"){
                        $("#partnerQQ").val("");
                    }else{
                        $("#partnerQQ").val(data.partnerQQ);
                    }
                    if(data.qqCodeUrl == null || data.qqCodeUrl == "null"){
                        $("#printFileDetail1").html("")
                        $("#projectyFil1").val("");
                    }else{
                        $("#printFileDetail1").html(data.qqCodeUrl.split("/")[data.qqCodeUrl.split("/").length-1])
                        $("#projectyFil1").val(data.qqCodeUrl);
                    }
                    if(data.weixinAccount == null || data.weixinAccount == "null"){
                        $("#weixinAccount").val("");
                    }else{
                        $("#weixinAccount").val(data.weixinAccount);
                    }
                    if(data.weixinCodeUrl == null || data.weixinCodeUrl == "null"){
                        $("#printFileDetail2").html("")
                        $("#projectyFil2").val("");
                    }else{
                        $("#printFileDetail2").html(data.weixinCodeUrl.split("/")[data.weixinCodeUrl.split("/").length-1])
                        $("#projectyFil2").val(data.weixinCodeUrl);
                    }
                    if(data.email == null || data.email == "null"){
                        $("#email").val("");
                    }else{
                        $("#email").val(data.email);
                    }
                    if(data.panoramicImage == null || data.panoramicImage == "null"){
                        $("#printFileDetail3").html("")
                        $("#projectyFil3").val("");
                    }else{
                        $("#printFileDetail3").html(data.panoramicImage.split("/")[data.panoramicImage.split("/").length-1])
                        $("#projectyFil3").val(data.panoramicImage);
                    }
                    if(data.cardSound == null || data.cardSound == "null"){
                        $("#printFileDetail4").html("")
                        $("#projectyFil4").val("");
                    }else{
                        $("#printFileDetail4").html(data.cardSound.split("/")[data.cardSound.split("/").length-1])
                        $("#projectyFil4").val(data.cardSound);
                    }
                    if(data.cardMedia == null || data.cardMedia == "null"){
                        $("#printFileDetail5").html("")
                        $("#projectyFil5").val("");
                    }else{
                        $("#printFileDetail5").html(data.cardMedia.split("/")[data.cardMedia.split("/").length-1])
                        $("#projectyFil5").val(data.cardMedia);
                    }
                } else {
                    alert(res.msg);
                }
            },
            error: function (res) {
                alert(res);
            }
        });


    }
    $("#editvCard").click(function () {
        if ($("#jobTitle").val() == "") {
            alert("职位名称不能为空");
            return;
        }
        if ($("#homeURL").val() == "") {
            alert("主页网址不能为空");
            return;
        }

        if ($("#partnerQQ").val() == "") {
            alert("合伙人QQ不能为空");
            return;
        }
        if ($("#projectyFil1").val() == "") {
            alert("合伙人QQ二维码不能为空");
            return;
        }
        if ($("#weixinAccount").val() == "") {
            alert("合伙人微信账号不能为空");
            return;
        }
        if ($("#projectyFil2").val() == "") {
            alert("合伙人微信二维码不能为空");
            return;
        }
        if ($("#email").val() == "") {
            alert("合伙人邮箱不能为空");
            return;
        }
        if ($("#projectyFil3").val() == "") {
            alert("全景图不能为空");
            return;
        }
        if ($("#projectyFil4").val() == "") {
            alert("名片声音不能为空");
            return;
        }
        if ($("#cardMediaTitle").val() == "") {
            alert("视频标题不能为空");
            return;
        }
        if ($("#projectyFil5").val() == "") {
            alert("名片视频不能为空");
            return;
        }
        var partner = {
            partnerId: partnerId,//合伙人id，系统生成，修改需要传入
            partnerQQ: $("#partnerQQ").val(),//合伙人联系qq
            qqCodeUrl: $("#projectyFil1").val(),//QQ二维码
            weixinAccount: $("#weixinAccount").val(),//微信账号
            weixinCodeUrl: $("#projectyFil2").val(),//微信二维码
            email: $("#email").val(),//邮箱
            panoramicImage: $("#projectyFil3").val(),//全景图
            cardSound: $("#projectyFil4").val(),//名片声音
            cardMedia: $("#projectyFil5").val(), //名片视频
            jobTitle:$("#jobTitle").val(),//职位
            cardMediaTitle:$("#cardMediaTitle").val(),//视频标题
            homeURL:$("#homeURL").val()//主页地址
        };

        $.ajax({
            url: 'apis/user/updatePartnerCard',
            type: 'post',
            data: {
                "partner": JSON.stringify(partner),
            },
            dataType: 'json',
            contentType: 'application/json',
            success: function (res) {
                if(res.httpCode == 200){
//                    console.log(res);
                    window.location.reload();
                } else {
                    alert(res.msg);
                }
            },
            error: function (res) {
                alert(res);
            }
        });
    })
    //获取通讯录二维码vCard
    function tovCard(id) {
        $.ajax({
            url: '/apis/user/getPartnerVCardImage',
            type: 'post',
            data: {
                "partnerId": id,
            },
            dataType: 'json',
            contentType: 'application/json',
            success: function (res) {
                if(res.httpCode == 200){
//                    console.log(res);
                    $("#gray_bg").show();
                    $("#gray_bg").css({"height": $(document).height()});
                    $("#qrCodeDiadog").center();
                    $("#qrCodeDiadog").show();
                    $("#qrCode").attr("src", "apis" + res.data + "");
                } else {
                    alert(res.msg);
                }
            },
            error: function (res) {
                alert(res);
            }
        });
    }
    function toEditpartner(id, pname, cname, phone, appid, wxsecret, miniAppPhone,img,kind) {
        partnerId = id;
        $("#gray_bg").show();
        $("#gray_bg").css({"height": $(document).height()});
        $("#editDiadog").show();
        $("#editDiadog").center();
        $("#diadogTitle").html("修改合伙人信息")
        $("#editPartner").show();
        $("#savePartner").hide();
        $("#admin").hide();

        $("#partnerName").val(pname);
        $("#companyName").val(cname);
        $("#wxAppId").val(appid);
        $("#wxSecret").val(wxsecret);
        $("#linkPhone").val(phone);
        $("#miniAppPhone").val(miniAppPhone);
        $("#avatar").val(img);
        $("#imgName").attr('src', img);
        if(kind == "A"){
            $("#toFactorTypeText").html("合伙人有产品档案");
            partnerType = kind;
        }else if(kind == "B"){
            $("#toFactorTypeText").html("合伙人只做展示");
            partnerType = kind;
        }else{
            $("#toFactorTypeText").html("两个都有");
            partnerType = kind;
        }
    }
    //    修改账号
    function toEditaccount(id, adminAccount) {
        partnerId = id;
        $("#gray_bg").show();
        $("#gray_bg").css({"height": $(document).height()});
        $("#editAccountDiadog").show();
        $("#editAccountDiadog").center();

        $("#account").val(adminAccount);
    }
    //    查看二维码
    function toCode(id) {
        $.ajax({
            url: 'apis/user/getpartnerwxacode',
            type: 'post',
            data: {
                "partnerId": id
            },
            dataType: 'json',
            success: function (data, status, xhr) {
                if (data.httpCode == 200) {
                    $("#gray_bg").show();
                    $("#gray_bg").css({"height": $(document).height()});
                    $("#qrCodeDiadog").center();
                    $("#qrCodeDiadog").show();
                    $("#qrCode").attr("src", "apis" + data.data + "");
                } else {
                    alert(data.msg);
                }
            }
        })
    }
    //    添加合伙人
    $("#addPartner").click(function () {
        $("#gray_bg").show();
        $("#gray_bg").css({"height": $(document).height()});
        $("#editDiadog").show();
        $("#diadogTitle").html("添加合伙人信息");
        $("#editDiadog").center();
        $("#editPartner").hide();
        $("#savePartner").show();
        $("#admin").show();

        $("#imgName").removeAttr("src");
    })
    $("#savePartner").click(function () {
        if ($("#partnerName").val() == "") {
            alert("用户名不能为空");
            return;
        }
        if ($("#companyName").val() == "") {
            alert("企业名不能为空");
            return;
        }
        if ($("#wxAppId").val() == "") {
            alert("微信AppId不能为空");
            return;
        }
        if ($("#wxSecret").val() == "") {
            alert("微信App密钥不能为空");
            return;
        }
        if ($("#linkPhone").val() == "") {
            alert("联系电话不能为空");
            return;
        }
        if ($("#miniAppPhone").val() == "") {
            alert("管理员手机号不能为空");
            return;
        }
        var linkPhone = $("#linkPhone").val();
        if (linkPhone && /^1[3|4|5|7|8]\d{9}$/.test(linkPhone)) {

        } else {
            alert("请输入正确联系电话")
            return;
        }
        var account = $("#miniAppPhone").val();
        if (account && /^1[3|4|5|7|8]\d{9}$/.test(account)) {

        } else {
            alert("请输入正确管理员手机号")
            return;
        }
        if ($("#adminAccount").val() == "") {
            alert("管理员账号不能为空");
            return;
        }
        if($("#avatar").val() == ""){
            alert("请上传合伙人logo图像");
            return;
        }
        if ($("#toFactorTypeText").html() == "选择类型") {
            alert("请选择合伙人类型");
            return;
        }

        var partnerName = $("#partnerName").val();
        var companyName = $("#companyName").val();
        var wxAppId = $.trim($("#wxAppId").val());
        var wxSecret = $.trim($("#wxSecret").val());
        var linkPhone = $("#linkPhone").val();
        var miniAppPhone = $("#miniAppPhone").val();
        var adminAccount = $("#adminAccount").val();
        var data = {
            partnername: partnerName,
            companyname: companyName,
            wxappid: wxAppId,
            wxsecret: wxSecret,
            linkphone: linkPhone,
            miniappphone: miniAppPhone,
            adminaccount: adminAccount,
            avataImage:$("#avatar").val(),
            partnerKind:partnerType
        }
        $.ajax({
            url: 'apis/user/addpartnerclient',
            type: 'post',
            data: {
                "partner": JSON.stringify(data)
            },
            dataType: 'json',
            success: function (data, status, xhr) {
                if (data.httpCode == 200) {
                    $("#gray_bg").hide();
                    $("#editDiadog").hide();
                    window.location.reload();
                } else {
                    alert(data.msg);
                }
            }
        });
    })
    //    修改合伙人
    $("#editPartner").click(function () {
        if ($("#partnerName").val() == "") {
            alert("用户名不能为空");
            return;
        }
        if ($("#companyName").val() == "") {
            alert("企业名不能为空");
            return;
        }
        if ($("#wxAppId").val() == "") {
            alert("微信AppId不能为空");
            return;
        }
        if ($("#wxSecret").val() == "") {
            alert("微信App密钥不能为空");
            return;
        }
        if ($("#linkPhone").val() == "") {
            alert("联系电话不能为空");
            return;
        }
        if ($("#miniAppPhone").val() == "") {
            alert("管理员手机号不能为空");
            return;
        }
        var linkPhone = $("#linkPhone").val();
        if (linkPhone && /^1[3|4|5|7|8]\d{9}$/.test(linkPhone)) {

        } else {
            alert("请输入正确联系电话")
            return;
        }
        var account = $("#miniAppPhone").val();
        if (account && /^1[3|4|5|7|8]\d{9}$/.test(account)) {

        } else {
            alert("请输入正确管理员手机号")
            return;
        }
        if($("#avatar").val() == ""){
            alert("请上传合伙人logo图像");
            return;
        }
        if ($("#toFactorTypeText").html() == "选择类型") {
            alert("请选择合伙人类型");
            return;
        }

        var data = {
            partnerid: partnerId,
            partnername: $("#partnerName").val(),
            companyname: $("#companyName").val(),
            wxappid: $.trim($("#wxAppId").val()),
            wxsecret: $.trim($("#wxSecret").val()),
            linkphone: $("#linkPhone").val(),
            miniappphone: $("#miniAppPhone").val(),
            avataImage:$("#avatar").val(),
            partnerKind:partnerType
        }
        $.ajax({
            url: 'apis/user/updatepartnerclient',
            type: 'post',
            data: {
                "partner": JSON.stringify(data)
            },
            dataType: 'json',
            success: function (data, status, xhr) {
                if (data.httpCode == 200) {
                    $("#gray_bg").hide();
                    $("#editDiadog").hide();
                    window.location.reload();
                } else {
                    alert(data.msg);
                }
            }
        });
    })
    //    修改账号
    $("#saveAccount").click(function () {
        var data = {
            partnerid: partnerId,
            adminaccount: $("#account").val()
        }
        $.ajax({
            url: 'apis/user/changepartneraccount',
            type: 'post',
            data: {
                "partner": JSON.stringify(data)
            },
            dataType: 'json',
            success: function (data, status, xhr) {
                if (data.httpCode == 200) {
                    $("#gray_bg").hide();
                    $("#editAccountDiadog").hide();
                    window.location.reload();
                } else {
                    alert(data.msg);
                }
            }
        });
    });
    //垂直居中
    jQuery.fn.center = function () {
        this.css("position", "absolute");
        this.css("top", ( $(window).height() - this.height() ) / 2 + $(window).scrollTop() + "px");
        this.css("left", ( $(window).width() - this.width() ) / 2 + $(window).scrollLeft() + "px");
        return this;
    }
    $(".close").click(function () {
            $("#gray_bg").hide();
            $("#editDiadog").hide();
            $("#editAccountDiadog").hide();
            $("#qrCodeDiadog").hide();
            $("#addressDialog").hide();
            $("#editvCardDiadog").hide();

            $("#partnerName").val("");
            $("#companyName").val("");
            $("#wxAppId").val("");
            $("#wxSecret").val("");
            $("#linkPhone").val("");
            $("#miniAppPhone").val("");
            $("#adminAccount").val("");
            $("#partnerAddress").val("");
            $("#lat").val("");
            $("#lng").val("");
        }
    )
//地图
    function toMap(id) {
        partnerId = id;
        $("#gray_bg").show();
        $("#gray_bg").css({"height": $(document).height()});
        $("#addressDialog").show();
        $("#addressDialog").center();

        $.ajax({
            url: 'apis/user/getPartnerAddress',
            type: 'post',
            data: {
                "partnerId": partnerId,
            },
            dataType: 'json',
            contentType: 'application/json',
            success: function (res) {
                if (res.httpCode == 200) {
//                    console.log(res);
                    var address = res.data.address;
                    var lat = res.data.latitude;
                    var lng = res.data.longitude;
                    if (address != null) {
                        $("#partnerAddress").val(address);
                        $("#lat").val(lat);
                        $("#lng").val(lng);

                        var curPlace = new qq.maps.LatLng(lat, lng);
                        map.setCenter(curPlace);
                        map.zoomTo(18);
                        if (marker != null) {
                            marker.setMap(null);
                        }
                        //设置marker标记
                        marker = new qq.maps.Marker({
                            map: map,
                            position: curPlace
                        });
                    } else {

                    }

                } else {
                    alert(res.msg);
                }
            },
            error: function (res) {
                alert(res);
            }
        });
    }

    $("#btnGeoCoder").click(function () {
        $.ajax({
            url: 'apis/user/getMapAddressGeoCoder',
            type: 'post',
            data: {
                "address": $("#partnerAddress").val()
            },
            dataType: 'json',
            success: function (data, status, xhr) {
                if (data.httpCode == 200) {
                    var curPlace = new qq.maps.LatLng(data.data.latitude, data.data.longitude);
                    map.setCenter(curPlace);
                    map.zoomTo(18);
                    if (marker != null) {
                        marker.setMap(null);
                    }
                    //设置marker标记
                    marker = new qq.maps.Marker({
                        map: map,
                        position: curPlace
                    });
                    $("#lat").val(marker.position.lat);
                    $("#lng").val(marker.position.lng);
                } else {
                    alert(data.msg);
                }
            }
        });
    })
    $("#sureAddr").click(function () {
        if ($("#partnerAddress").val() == "") {
            alert("地址不能为空");
            return;
        }
        var partner = {
            partnerId: partnerId,
            address: $("#partnerAddress").val(),
            latitude: $("#lat").val(),
            longitude: $("#lng").val()
        };
        $.ajax({
            url: 'apis/user/updatePartnerAddress',
            type: 'post',
            data: {
                "partner": JSON.stringify(partner),
            },
            dataType: 'json',
            contentType: 'application/json',
            success: function (res) {
                if (res.httpCode == 200) {
//                    console.log(res);
                    window.location.reload();
                } else {
                    alert(res.msg);
                }
            },
            error: function (res) {
                alert(res);
            }
        });
    })
    function toErCode(id) {
        $.ajax({
            url: '/apis/user/getPartnerBPageCode',
            type: 'post',
            data: {
                "partnerId": id,
            },
            dataType: 'json',
            contentType: 'application/json',
            success: function (res) {
                if(res.httpCode == 200){
//                    console.log(res);
                    $("#gray_bg").show();
                    $("#gray_bg").css({"height": $(document).height()});
                    $("#qrCodeDiadog").center();
                    $("#qrCodeDiadog").show();
                    $("#qrCode").attr("src", "apis" + res.data + "");
                } else {
                    alert(res.msg);
                }
            },
            error: function (res) {
                alert(res);
            }
        });
    }
</script>
</body>
</html>